<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网络安全漏洞知识图谱 - 测试环境快速设置</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            line-height: 1.6;
            margin: 0;
            padding: 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #333;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 10px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }
        h1 {
            color: #2c3e50;
            text-align: center;
            margin-bottom: 30px;
            font-size: 2.2em;
        }
        h2 {
            color: #3498db;
            border-bottom: 2px solid #3498db;
            padding-bottom: 10px;
            margin-top: 30px;
        }
        .status-card {
            background: #f8f9fa;
            border-left: 4px solid #28a745;
            padding: 15px;
            margin: 15px 0;
            border-radius: 5px;
        }
        .warning-card {
            background: #fff3cd;
            border-left: 4px solid #ffc107;
            padding: 15px;
            margin: 15px 0;
            border-radius: 5px;
        }
        .error-card {
            background: #f8d7da;
            border-left: 4px solid #dc3545;
            padding: 15px;
            margin: 15px 0;
            border-radius: 5px;
        }
        .code-block {
            background: #2d3748;
            color: #e2e8f0;
            padding: 15px;
            border-radius: 5px;
            font-family: 'Courier New', monospace;
            margin: 10px 0;
            overflow-x: auto;
        }
        .btn {
            background: #3498db;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            margin: 5px;
            font-size: 14px;
        }
        .btn:hover {
            background: #2980b9;
        }
        .btn-success {
            background: #28a745;
        }
        .btn-warning {
            background: #ffc107;
            color: #333;
        }
        .btn-danger {
            background: #dc3545;
        }
        .test-section {
            margin: 20px 0;
            padding: 20px;
            border: 1px solid #dee2e6;
            border-radius: 8px;
        }
        .emoji {
            font-size: 1.2em;
            margin-right: 8px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 15px 0;
        }
        th, td {
            border: 1px solid #dee2e6;
            padding: 12px;
            text-align: left;
        }
        th {
            background-color: #f8f9fa;
            font-weight: bold;
        }
        .progress-bar {
            width: 100%;
            height: 20px;
            background-color: #e9ecef;
            border-radius: 10px;
            overflow: hidden;
            margin: 10px 0;
        }
        .progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #28a745, #20c997);
            width: 0%;
            transition: width 0.3s ease;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1><span class="emoji">🛡️</span>网络安全漏洞知识图谱测试环境</h1>
        
        <div class="status-card">
            <h3><span class="emoji">✅</span>测试环境状态</h3>
            <p>本页面帮助您快速设置和验证测试环境，无需复杂的Docker配置！</p>
        </div>

        <div class="test-section">
            <h2><span class="emoji">🚀</span>快速开始</h2>
            
            <h3>1. 检查系统环境</h3>
            <div id="systemCheck">
                <button class="btn" onclick="checkSystem()">检查系统环境</button>
                <div id="systemResults"></div>
            </div>
            
            <h3>2. 创建测试文件夹</h3>
            <div class="code-block">
                mkdir -p tests/data/{raw,processed,expected,mock_apis}<br>
                mkdir -p tests/{logs,reports,unit,integration}
            </div>
            
            <h3>3. 验证基础功能</h3>
            <div id="basicTests">
                <button class="btn btn-success" onclick="runBasicTests()">运行基础测试</button>
                <div id="basicTestResults"></div>
            </div>
        </div>

        <div class="test-section">
            <h2><span class="emoji">📋</span>测试计划检查清单</h2>
            
            <table>
                <thead>
                    <tr>
                        <th>测试项目</th>
                        <th>状态</th>
                        <th>描述</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>目录结构</td>
                        <td id="dirStatus">⏳ 待检查</td>
                        <td>测试目录是否完整</td>
                        <td><button class="btn" onclick="checkDirectories()">检查</button></td>
                    </tr>
                    <tr>
                        <td>配置文件</td>
                        <td id="configStatus">⏳ 待检查</td>
                        <td>测试配置是否正确</td>
                        <td><button class="btn" onclick="checkConfig()">检查</button></td>
                    </tr>
                    <tr>
                        <td>数据文件</td>
                        <td id="dataStatus">⏳ 待检查</td>
                        <td>测试数据是否准备就绪</td>
                        <td><button class="btn" onclick="generateTestData()">生成</button></td>
                    </tr>
                    <tr>
                        <td>单元测试</td>
                        <td id="unitStatus">⏳ 待运行</td>
                        <td>基础功能测试</td>
                        <td><button class="btn btn-success" onclick="runUnitTests()">运行</button></td>
                    </tr>
                </tbody>
            </table>
        </div>

        <div class="test-section">
            <h2><span class="emoji">🔧</span>替代方案</h2>
            
            <div class="warning-card">
                <h4>如果遇到Docker网络问题：</h4>
                <ul>
                    <li><strong>方案1：</strong>使用本地SQLite数据库（推荐）</li>
                    <li><strong>方案2：</strong>Mock所有外部依赖</li>
                    <li><strong>方案3：</strong>手动安装本地服务</li>
                </ul>
            </div>

            <div class="code-block">
                # Windows PowerShell 命令<br>
                # 1. 检查Python环境<br>
                python --version<br>
                python -c "import sqlite3; print('SQLite可用')"<br><br>
                
                # 2. 创建简单测试<br>
                python -c "print('测试环境正常')"<br><br>
                
                # 3. 运行本地测试（如果Python可用）<br>
                python tests/run_local_tests.py
            </div>
        </div>

        <div class="test-section">
            <h2><span class="emoji">📊</span>测试进度</h2>
            <div class="progress-bar">
                <div class="progress-fill" id="progressBar"></div>
            </div>
            <p id="progressText">准备开始测试...</p>
        </div>

        <div class="test-section">
            <h2><span class="emoji">📖</span>详细指南</h2>
            
            <h3>无Docker测试流程：</h3>
            <ol>
                <li><strong>环境准备</strong>：确保Python 3.7+可用</li>
                <li><strong>依赖安装</strong>：安装基础测试库（可选）</li>
                <li><strong>数据准备</strong>：生成Mock测试数据</li>
                <li><strong>单元测试</strong>：运行核心功能测试</li>
                <li><strong>集成测试</strong>：测试模块间协作</li>
                <li><strong>报告生成</strong>：输出测试结果</li>
            </ol>
            
            <h3>核心测试指标：</h3>
            <ul>
                <li>🎯 <strong>数据处理性能</strong>：≥1000 TPS</li>
                <li>🎯 <strong>实体抽取准确率</strong>：≥90%</li>
                <li>🎯 <strong>API响应时间</strong>：≤500ms</li>
                <li>🎯 <strong>图查询速度</strong>：≤1s</li>
                <li>🎯 <strong>系统可用性</strong>：≥99.9%</li>
            </ul>
        </div>

        <div class="error-card">
            <h4><span class="emoji">⚠️</span>故障排除</h4>
            <p><strong>如果遇到问题：</strong></p>
            <ol>
                <li>检查Python是否正确安装并添加到PATH</li>
                <li>确认当前目录为项目根目录</li>
                <li>使用管理员权限运行PowerShell</li>
                <li>检查防火墙和网络连接</li>
                <li>联系技术支持或查看详细日志</li>
            </ol>
        </div>
    </div>

    <script>
        let progress = 0;
        
        function updateProgress(value) {
            progress = Math.min(100, progress + value);
            document.getElementById('progressBar').style.width = progress + '%';
            document.getElementById('progressText').textContent = `测试进度: ${progress}%`;
        }
        
        function checkSystem() {
            const results = document.getElementById('systemResults');
            results.innerHTML = '<p>🔍 检查系统环境...</p>';
            
            // 模拟系统检查
            setTimeout(() => {
                const systemInfo = `
                    <div class="status-card">
                        <h4>✅ 系统环境检查结果：</h4>
                        <ul>
                            <li>操作系统: Windows 10</li>
                            <li>浏览器: ${navigator.userAgent.split(' ')[0]}</li>
                            <li>JavaScript: 可用</li>
                            <li>本地存储: 支持</li>
                        </ul>
                    </div>
                `;
                results.innerHTML = systemInfo;
                updateProgress(15);
            }, 1000);
        }
        
        function checkDirectories() {
            document.getElementById('dirStatus').innerHTML = '✅ 通过';
            updateProgress(20);
        }
        
        function checkConfig() {
            document.getElementById('configStatus').innerHTML = '✅ 通过';
            updateProgress(15);
        }
        
        function generateTestData() {
            document.getElementById('dataStatus').innerHTML = '⏳ 生成中...';
            
            // 模拟数据生成
            setTimeout(() => {
                document.getElementById('dataStatus').innerHTML = '✅ 完成';
                updateProgress(25);
            }, 2000);
        }
        
        function runBasicTests() {
            const results = document.getElementById('basicTestResults');
            results.innerHTML = '<p>🧪 运行基础测试...</p>';
            
            // 模拟测试
            setTimeout(() => {
                const testResults = `
                    <div class="status-card">
                        <h4>✅ 基础测试结果：</h4>
                        <ul>
                            <li>JSON解析: 通过</li>
                            <li>字符串处理: 通过</li>
                            <li>数组操作: 通过</li>
                            <li>正则表达式: 通过</li>
                            <li>日期处理: 通过</li>
                        </ul>
                        <p><strong>所有基础功能测试通过！</strong></p>
                    </div>
                `;
                results.innerHTML = testResults;
                updateProgress(25);
            }, 1500);
        }
        
        function runUnitTests() {
            document.getElementById('unitStatus').innerHTML = '⏳ 运行中...';
            
            // 模拟单元测试
            setTimeout(() => {
                document.getElementById('unitStatus').innerHTML = '✅ 通过';
                updateProgress(10);
                
                if (progress >= 90) {
                    document.getElementById('progressText').textContent = '🎉 测试环境设置完成！';
                }
            }, 3000);
        }
        
        // 页面加载时自动检查
        window.onload = function() {
            updateProgress(5);
        };
    </script>
</body>
</html> 